/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.factory;

import java.util.Set;
import ru.jSky.interfaces.Major;
import ru.jSky.producer.Producer;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.Keyword;
import ru.jSky.interfaces.additional.Enchantmentable;
import ru.jSky.interfaces.additional.KeywordDescribed;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class MajorProducerFactory {
    
    private static MajorProducerFactory instance = new MajorProducerFactory();

    public static MajorProducerFactory create(){
        return instance;
    }
    
    private static Producer<Major, String> edidProducer = new Producer<Major, String>() {
        @Override
        public String produce(Major fromObject) {
            return fromObject.getEDID();
        }
    };
    private static Producer<Major, FormID> formIdProducer = new Producer<Major, FormID>() {
        @Override
        public FormID produce(Major fromObject) {
            return fromObject.getForm();
        }
    };
    private static Producer<Enchantmentable, Enchantment> enchantmentProducer = new Producer<Enchantmentable, Enchantment>() {
        @Override
        public Enchantment produce(Enchantmentable fromObject) {
            return fromObject.getEnchantment();
        }
    };
    private static Producer<KeywordDescribed, Set<Keyword>> keywordsProducer = new Producer<KeywordDescribed, Set<Keyword>>() {
        @Override
        public Set<Keyword> produce(KeywordDescribed fromObject) {
            return fromObject.getKeywords();
        }
    };

    public <T extends Major> Producer<T, String> createEdidProducer() {
        return (Producer<T, String>) MajorProducerFactory.edidProducer;
    }

    public <T extends Major> Producer<T, FormID> createFormIdProducer() {
        return (Producer<T, FormID>) MajorProducerFactory.formIdProducer;
    }

    public <T extends Enchantmentable> Producer<T, Enchantment> createEnchantmentProducer() {
        return (Producer<T, Enchantment>) MajorProducerFactory.enchantmentProducer;
    }

    public <T extends KeywordDescribed> Producer<T, Set<Keyword>> createKeywordsProducer() {
        return (Producer<T, Set<Keyword>>) MajorProducerFactory.keywordsProducer;
    }
}
